home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 43.zip / Sources C- WorkDisk V.adf / peck / list2.c < prev    next >
C/C++ Source or Header  |  1987-02-15  |  628b  |  40 lines

  1.  
  2. /* list example 3.1. p.57 Peck */
  3.  
  4. #include "exec/types.h"
  5. #include "exec/lists.h"
  6.  
  7. struct MyListItem
  8. {
  9.  struct Node n;
  10.  int x,y ;
  11. };
  12.  
  13. main()
  14. {
  15.  struct MyListItem mli[9];
  16.  struct MyListItem *mynode;
  17.  struct List MyListHead;
  18.  int i;
  19.  
  20.  NewList(&MyListHead); /* init the list header */
  21.  
  22.  
  23.  for(i=0;i<9;i++)
  24.  {
  25.   mli[i].x=i;
  26.   mli[i].y=i;
  27.   AddTail(&MyListHead, &mli[i]);
  28.   printf("Just included item nr %d whose (x,y) is (%d,%d)\n",i,mli[i].x,mli[i].y);
  29.  }
  30.  
  31.  while((mynode = RemTail(&MyListHead)) != NULL)
  32.  {
  33.   printf("Just removed item whose (x,y) data is (%d,%d)\n",mynode->x,mynode->y);
  34.  }
  35.  
  36. } /* ====== end of main ====== */
  37.  
  38.  
  39.  
  40.